<?php
require_once("config.inc.php");

if (isset($_GET['s']))
{
  if ($_GET['s']=="start") {
  	$string = "<?php\n return true;\n?>";
    echo '<script language="javascript" type="text/javascript">window.open("get_request.php");</script>';
	echo '<script language="javascript" type="text/javascript">window.open("handle_request.php");</script>';
	echo '<script language="javascript" type="text/javascript">window.open("handle_comment.php");</script>';
	$status = true;
  } elseif ($_GET['s']=="stop") {
  	$string = "<?php\n return false;\n?>";
	$status = false;
  } else
    die("Err start:stop");
  
  write_inc($key_file,$string,true);
} else {
	$status = include $key_file;
}

function write_inc($path,$strings,$type=false)
{  
  $path=dirname(__FILE__)."/".$path;
  if ($type==false)
    file_put_contents($path,$strings,FILE_APPEND);
  else
    file_put_contents($path,$strings);
}

?>
<html>
<head>
<title>控制台</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.ss {
	border: 1px solid #666;
	height: 60px;
	width: 120px;
	text-align: center;
	padding-top: 30px;
	margin: 10px;
}
.ss a {
	color: #333;
	font-family: "黑体", "华文细黑", "方正姚体";
	font-size: 16px;
	text-decoration: none;
}
#status {
	height: 100px;
	width: 600px;
	padding-top: 50px;
	font-size: 36px;
}
.start {
	background-color: #0F0;
}
.stop {
	background-color: #F00;
}
#active {
	background-color: #999;
}
-->
</style>
</head>
<body>
<center>
<div id="status" class='<?php if($status) { echo "start"; } else { echo "stop"; } ?>'><?php if($status) { echo "运行中..."; } else { echo "停止"; } ?></div>
<div class="ss" <?php if($status) { echo "id='active'"; } ?>><a href="?s=start" title="开始">开始</a></div>
<div class="ss" <?php if(!$status) { echo "id='active'"; } ?>><a href="?s=stop" title="停止">停止</a></div>
</center>
</body>
</html>